Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search std for module name when using with module. #7753

Merged
merged 3 commits into from
Oct 4, 2024
Merged

Conversation

dnwpark
Copy link
Contributor

@dnwpark dnwpark commented Sep 16, 2024

related #7737

@dnwpark dnwpark requested a review from msullivan September 16, 2024 17:01
Copy link
Member

@msullivan msullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is unfortunately another location where names get resolved that probably also needs to be updated: https://github.com/edgedb/edgedb/blob/6ba3152590fa55d9b779f790bf0ee68065080767/edb/edgeql/tracer.py#L371-L419

That operates when loading schemas, so you'll want to try write test_schema.py tests that load schemas that have this sort of WITH module nonsense inside a computed or an alias, I guess.

Comment on lines 10034 to 10035
create module std::test;
create function std::test::Foo(x: int64) -> int64 using(x);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a std::_test module and a std::_test::abs function; we can use those

Copy link
Member

@msullivan msullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more thing we need to make sure works right: we run expressions through a "normalization" pass before storing them in the schema: https://github.com/edgedb/edgedb/blob/master/edb/edgeql/compiler/normalization.py

The normalization pass turns all of the names into fully qualified names. For example:

_localdev:main> create alias X := (with module math select sqrt(35));
OK: CREATE ALIAS
_localdev:main> describe schema as sdl;
{
  'module default {
    alias X := (
        select
            math::sqrt(35)
    );
};',
}

We'll want to test that works too. Unfortunately I don't think we have direct normalization tests (probably a mistake), but you can test it with test_schema.py tests that do describes.

@dnwpark
Copy link
Contributor Author

dnwpark commented Oct 3, 2024

@msullivan Not entirely sure this is what you had in mind, but I've added schema and describe tests.

@dnwpark dnwpark marked this pull request as ready for review October 4, 2024 18:04
@dnwpark
Copy link
Contributor Author

dnwpark commented Oct 4, 2024

@msullivan the tracer code already did what we wanted, it was just the schema that needed updating.

@dnwpark dnwpark merged commit 23d0bff into master Oct 4, 2024
24 checks passed
@dnwpark dnwpark deleted the with-module-std branch October 4, 2024 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants